<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>组件化</title>
</head>
<body>
<div id="app">
    <input type="text" v-model="parentMsg">
    <my-component :message="parentMsg"></my-component>
    <my-btn></my-btn>
    <my-btn></my-btn>
</div>
</body>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    Vue.component('my-component', {
        template: '<div>{{ message }}</div>',
        props: ['message']

    })
    Vue.component('my-btn', {
        template: '<button @click="counter++">{{ counter }}</button>',
        data: function () {
            return {
                counter: 0
            }
        }
    })
    var app = new Vue({
        el: '#app',
        data: {
            parentMsg: ''
        }
    })
</script>
</html>
